initializeWindows = function(){

	MUI.loginWindow = function() {
		new MUI.Modal({
			id: 'login',
			title: 'CAP4J 3.0 Prototype',			
			contentURL: 'login/loginwindow.jsp',
			type: 'modal',
			width: 250,
			height: 110,
			collapsible:false,
			padding: { top: 10, right: 10, bottom: 5, left: 10 },
			toolbar2: true,
			toolbar2URL: 'login/loginwindowtoolbar.inc',
			scrollbars: false,
			closable: false,
			modalOverlayClose: false
		});
	};
	
	
	// Build windows onLoad
	MUI.loginWindow();
	MUI.myChain.callChain();
};

addKeyEvents = function(){
	document.body.addEvent('keydown', function(event){
		if (event.key == 'enter') {
			if ($('loginForm')) {
				$('loginForm').submit();
			}
		}
	});
};

// Initialize MochaUI when the DOM is ready
window.addEvent('load', function(){ //using load instead of domready for IE8

	MUI.myChain = new Chain();
	MUI.myChain.chain(
		function(){MUI.Desktop.initialize();},
		function(){initializeWindows();},
		function(){addKeyEvents();}
	).callChain();	

	
});
